//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS PinpointSMSVoice service.
///
/// Pinpoint SMS and Voice Messaging public facing APIs
public struct PinpointSMSVoice: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the PinpointSMSVoice client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "PinpointSMSVoice",
            serviceIdentifier: "sms-voice.pinpoint",
            signingName: "sms-voice",
            serviceProtocol: .restjson,
            apiVersion: "2018-09-05",
            endpoint: endpoint,
            errorType: PinpointSMSVoiceErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Create a new configuration set. After you create the configuration set, you can add one or more event destinations to it.
    @Sendable
    @inlinable
    public func createConfigurationSet(_ input: CreateConfigurationSetRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateConfigurationSetResponse {
        try await self.client.execute(
            operation: "CreateConfigurationSet", 
            path: "/v1/sms-voice/configuration-sets", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Create a new configuration set. After you create the configuration set, you can add one or more event destinations to it.
    ///
    /// Parameters:
    ///   - configurationSetName: The name that you want to give the configuration set.
    ///   - logger: Logger use during operation
    @inlinable
    public func createConfigurationSet(
        configurationSetName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateConfigurationSetResponse {
        let input = CreateConfigurationSetRequest(
            configurationSetName: configurationSetName
        )
        return try await self.createConfigurationSet(input, logger: logger)
    }

    /// Create a new event destination in a configuration set.
    @Sendable
    @inlinable
    public func createConfigurationSetEventDestination(_ input: CreateConfigurationSetEventDestinationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreateConfigurationSetEventDestinationResponse {
        try await self.client.execute(
            operation: "CreateConfigurationSetEventDestination", 
            path: "/v1/sms-voice/configuration-sets/{ConfigurationSetName}/event-destinations", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Create a new event destination in a configuration set.
    ///
    /// Parameters:
    ///   - configurationSetName: ConfigurationSetName
    ///   - eventDestination: 
    ///   - eventDestinationName: A name that identifies the event destination.
    ///   - logger: Logger use during operation
    @inlinable
    public func createConfigurationSetEventDestination(
        configurationSetName: String,
        eventDestination: EventDestinationDefinition? = nil,
        eventDestinationName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreateConfigurationSetEventDestinationResponse {
        let input = CreateConfigurationSetEventDestinationRequest(
            configurationSetName: configurationSetName, 
            eventDestination: eventDestination, 
            eventDestinationName: eventDestinationName
        )
        return try await self.createConfigurationSetEventDestination(input, logger: logger)
    }

    /// Deletes an existing configuration set.
    @Sendable
    @inlinable
    public func deleteConfigurationSet(_ input: DeleteConfigurationSetRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteConfigurationSetResponse {
        try await self.client.execute(
            operation: "DeleteConfigurationSet", 
            path: "/v1/sms-voice/configuration-sets/{ConfigurationSetName}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes an existing configuration set.
    ///
    /// Parameters:
    ///   - configurationSetName: ConfigurationSetName
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteConfigurationSet(
        configurationSetName: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteConfigurationSetResponse {
        let input = DeleteConfigurationSetRequest(
            configurationSetName: configurationSetName
        )
        return try await self.deleteConfigurationSet(input, logger: logger)
    }

    /// Deletes an event destination in a configuration set.
    @Sendable
    @inlinable
    public func deleteConfigurationSetEventDestination(_ input: DeleteConfigurationSetEventDestinationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteConfigurationSetEventDestinationResponse {
        try await self.client.execute(
            operation: "DeleteConfigurationSetEventDestination", 
            path: "/v1/sms-voice/configuration-sets/{ConfigurationSetName}/event-destinations/{EventDestinationName}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Deletes an event destination in a configuration set.
    ///
    /// Parameters:
    ///   - configurationSetName: ConfigurationSetName
    ///   - eventDestinationName: EventDestinationName
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteConfigurationSetEventDestination(
        configurationSetName: String,
        eventDestinationName: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteConfigurationSetEventDestinationResponse {
        let input = DeleteConfigurationSetEventDestinationRequest(
            configurationSetName: configurationSetName, 
            eventDestinationName: eventDestinationName
        )
        return try await self.deleteConfigurationSetEventDestination(input, logger: logger)
    }

    /// Obtain information about an event destination, including the types of events it reports, the Amazon Resource Name (ARN) of the destination, and the name of the event destination.
    @Sendable
    @inlinable
    public func getConfigurationSetEventDestinations(_ input: GetConfigurationSetEventDestinationsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> GetConfigurationSetEventDestinationsResponse {
        try await self.client.execute(
            operation: "GetConfigurationSetEventDestinations", 
            path: "/v1/sms-voice/configuration-sets/{ConfigurationSetName}/event-destinations", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Obtain information about an event destination, including the types of events it reports, the Amazon Resource Name (ARN) of the destination, and the name of the event destination.
    ///
    /// Parameters:
    ///   - configurationSetName: ConfigurationSetName
    ///   - logger: Logger use during operation
    @inlinable
    public func getConfigurationSetEventDestinations(
        configurationSetName: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetConfigurationSetEventDestinationsResponse {
        let input = GetConfigurationSetEventDestinationsRequest(
            configurationSetName: configurationSetName
        )
        return try await self.getConfigurationSetEventDestinations(input, logger: logger)
    }

    /// List all of the configuration sets associated with your Amazon Pinpoint account in the current region.
    @Sendable
    @inlinable
    public func listConfigurationSets(_ input: ListConfigurationSetsRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListConfigurationSetsResponse {
        try await self.client.execute(
            operation: "ListConfigurationSets", 
            path: "/v1/sms-voice/configuration-sets", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// List all of the configuration sets associated with your Amazon Pinpoint account in the current region.
    ///
    /// Parameters:
    ///   - nextToken: A token returned from a previous call to the API that indicates the position in the list of results.
    ///   - pageSize: Used to specify the number of items that should be returned in the response.
    ///   - logger: Logger use during operation
    @inlinable
    public func listConfigurationSets(
        nextToken: String? = nil,
        pageSize: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListConfigurationSetsResponse {
        let input = ListConfigurationSetsRequest(
            nextToken: nextToken, 
            pageSize: pageSize
        )
        return try await self.listConfigurationSets(input, logger: logger)
    }

    /// Create a new voice message and send it to a recipient's phone number.
    @Sendable
    @inlinable
    public func sendVoiceMessage(_ input: SendVoiceMessageRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> SendVoiceMessageResponse {
        try await self.client.execute(
            operation: "SendVoiceMessage", 
            path: "/v1/sms-voice/voice/message", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Create a new voice message and send it to a recipient's phone number.
    ///
    /// Parameters:
    ///   - callerId: The phone number that appears on recipients' devices when they receive the message.
    ///   - configurationSetName: The name of the configuration set that you want to use to send the message.
    ///   - content: 
    ///   - destinationPhoneNumber: The phone number that you want to send the voice message to.
    ///   - originationPhoneNumber: The phone number that Amazon Pinpoint should use to send the voice message. This isn't necessarily the phone number that appears on recipients' devices when they receive the message, because you can specify a CallerId parameter in the request.
    ///   - logger: Logger use during operation
    @inlinable
    public func sendVoiceMessage(
        callerId: String? = nil,
        configurationSetName: String? = nil,
        content: VoiceMessageContent? = nil,
        destinationPhoneNumber: String? = nil,
        originationPhoneNumber: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> SendVoiceMessageResponse {
        let input = SendVoiceMessageRequest(
            callerId: callerId, 
            configurationSetName: configurationSetName, 
            content: content, 
            destinationPhoneNumber: destinationPhoneNumber, 
            originationPhoneNumber: originationPhoneNumber
        )
        return try await self.sendVoiceMessage(input, logger: logger)
    }

    /// Update an event destination in a configuration set. An event destination is a location that you publish information about your voice calls to. For example, you can log an event to an Amazon CloudWatch destination when a call fails.
    @Sendable
    @inlinable
    public func updateConfigurationSetEventDestination(_ input: UpdateConfigurationSetEventDestinationRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdateConfigurationSetEventDestinationResponse {
        try await self.client.execute(
            operation: "UpdateConfigurationSetEventDestination", 
            path: "/v1/sms-voice/configuration-sets/{ConfigurationSetName}/event-destinations/{EventDestinationName}", 
            httpMethod: .PUT, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Update an event destination in a configuration set. An event destination is a location that you publish information about your voice calls to. For example, you can log an event to an Amazon CloudWatch destination when a call fails.
    ///
    /// Parameters:
    ///   - configurationSetName: ConfigurationSetName
    ///   - eventDestination: 
    ///   - eventDestinationName: EventDestinationName
    ///   - logger: Logger use during operation
    @inlinable
    public func updateConfigurationSetEventDestination(
        configurationSetName: String,
        eventDestination: EventDestinationDefinition? = nil,
        eventDestinationName: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdateConfigurationSetEventDestinationResponse {
        let input = UpdateConfigurationSetEventDestinationRequest(
            configurationSetName: configurationSetName, 
            eventDestination: eventDestination, 
            eventDestinationName: eventDestinationName
        )
        return try await self.updateConfigurationSetEventDestination(input, logger: logger)
    }
}

extension PinpointSMSVoice {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: PinpointSMSVoice, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
